# 新闻的颜色过滤



def hot_news_filter(index):
    if index == 1:
        return 'first'
    elif index == 2:
        return 'second'
    elif index == 3:
        return 'third'
    else:
        return ''

# 登陆验证
from functools import wraps
from flask import current_app, jsonify,g
from flask import session
from app.utils.response_code import RET
def user_login_data(view_func):
    @wraps(view_func)
    def wrapper(*args, **kwargs):
        # 1 用户登陆操作
        user_id = session.get('user_id')
        user = None
        if user_id:
            try:
                from app.models import User
                # user = User.query.filter(User.id == user_id).first()
                user = User.query.get(user_id)
            except Exception as e:
                current_app.logger.error(e)
        g.user = user
        return view_func(*args, **kwargs)
    return wrapper